// 1. 引入 express 模块
const express = require('express');

// 2. 创建应用对象
const app = express();

app.get('/', (req, resp) => {
    resp.send('Hello Express');
})

app.get('/user/:id', (req, resp) => {
    console.log(req.params)
    resp.send(`User ID: ${req.params.id}`);
})

// 托管静态资源文件夹
app.use(express.static('public'));

app.get('/about', (req, resp) => {
    resp.send('About Page');
});

// 3. 启动服务,调用listen方法,并指定端口号
app.listen(3000, () => {
  console.log('Server is running on http://localhost:3000');
});
